package com.twu.biblioteca;

import java.util.*;

/**
 * Created by archoud on 3/10/14.
 */
public class Menu {
    private Input input;
    private Output output;
    private Library library;
    private List<String> menuOptions = new ArrayList<String>();

    public Menu(Input input, Output output, Library library) {

        this.input = input;
        this.output = output;
        this.library = library;

        menuOptions.add("Display books");
        menuOptions.add("Checkout book");
    }

    public void display() {
        String header = "Main Menu:";
        output.printList(header, menuOptions);
    }

    public void runMenuChoice() {
        int choice = input.getUserChoice();
        while (choice < 0 || choice > 1){
            output.print("Select a valid option!");
            choice = input.getUserChoice();
        }
        if(choice == 0){
            library.printBooks();
        } else if(choice == 1){
            library.printBooks();
            library.checkout();
        }
    }

    public void greet() {
        output.print("Welcome to Biblioteca");
    }
}
